package li.webqq.api;

import li.http.Response;

import org.apache.log4j.Logger;

/**
 * @author 明伟
 */
public class LoginResponse extends Response {
    private static final Logger logger = Logger.getLogger(LoginResponse.class);

    private String flag;

    public String getFlag() {
        if (null == this.flag) {
            String body = super.getBody();
            logger.info(" getFlag() body=" + body);
            this.flag = body.substring(8, 9);
        }
        return this.flag;
    }

    // ptuiCB('0','0','http://web.qq.com/loginproxy.html?login2qq=1&webqq_type=10','0','登录成功！', '待定');
    public Boolean success() {
        return "0".equals(this.getFlag());
    }

    // ptuiCB('4','0','','0','您输入的验证码不正确，请重新输入。', '1055515958');
    public Boolean verifyCodeError() {
        return "4".equals(this.getFlag());
    }

    // ptuiCB('3','0','','0','您输入的帐号或密码不正确，请重新输入。', '1055515958');
    public Boolean accountError() {
        return "3".equals(this.getFlag());
    }

    public String getCheckSigUrl() {
        String body = super.getBody();
        logger.info(" getCheckSigUrl() body=" + body);
        String[] temp = body.split("[,]");
        String chechSigUrl = temp[2].replace("\'", "");
        logger.info("getCheckSigUrl temp[2]=" + chechSigUrl);
        return chechSigUrl;
    }

    // ptuiCB('24','0','','0','很遗憾，网络连接出现异常，请您检查是否禁用cookies。(2762999080)', '1055515958');
}